home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-14 | 3.0 KB | 103 lines | [TEXT/ttxt] |
- <<<
- -- moo: memory overhead overseer
- -- by Erik Neumann & Vidur Apparao, November 1994
- -- moo can be used to see whether memory is being used up between scenes
- /*
- How to use this memory utility:
- 1) open this file within ScriptX to define the functions contained herein.
- 2) in the listener type moo()
- 3) do some stuff (make objects, run your title, etc.)
- 4) type moo() again to see overall changes in memory.
- 5) you can run moo() as many times as you want.
- 6) if you want to reset moo, type: mooReset()
-
- The first time moo is run it will measure and remember the state of memory.
- After the first time, you will see a display like this:
-
- " free sys: 6102688 heap used: 658752 total heap: 946176"
- "delta free sys: 247280 delta heap used: -2368 delta total heap: 0"
- "cumul free sys: -1648 cumul used heap: -107296 cumul total heap: 0"
- "adj cumul free sys: -1648"
-
- free sys = the amount of free system memory (ie. non-ScriptX heap, which
- is where large data like bitmaps go)
- heap used = amount of ScriptX object heap now in use.
- total heap = total size of ScriptX object heap. When this goes up, the
- ScriptX heap has run out of memory and had to be expanded.
- adj cumul free sys = cumulative change in free system heap excluding expansion
- of the ScriptX heap.
-
- To make moo forget the current state and start over, type: mooReset().
-
- */
-
- global savefreesys := 0
- global savefreeheap := 0
- global savetotalheap := 0
- global startfreesys := 0
- global startfreeheap := 0
- global starttotalheap := 0
-
- function mooReset -> (
- savefreesys := 0
- savefreeheap := 0
- savetotalheap := 0
- startfreesys := 0
- startfreeheap := 0
- starttotalheap := 0
- )
-
- function moo -> (
- local caption
- garbagecollect()
-
- local newfreesys := totalfreesystemspace()
- local newfreeheap := totalfreeheapspace()
- local newtotalheap := totalheapspace()
- caption := (" free sys: " + (newfreesys as String) +
- " heap used: " + ((newtotalheap - newfreeheap) as String) +
- " total heap: " + (newtotalheap as String))
- print caption
-
- if (savefreesys = 0) do
- (
- savefreesys := newfreesys
- savefreeheap := newfreeheap
- savetotalheap := newtotalheap
- )
-
- caption := ("delta free sys: " +
- ((newfreesys - savefreesys) as String) +
- " delta heap used: " +
- (((newtotalheap - newfreeheap) - (savetotalheap - savefreeheap)) as String) +
- " delta total heap: " +
- ((newtotalheap - savetotalheap) as String))
- print caption
- savefreesys := newfreesys
- savefreeheap := newfreeheap
- savetotalheap := newtotalheap
-
- if (starttotalheap = 0) do
- (
- startfreesys := newfreesys
- startfreeheap := newfreeheap
- starttotalheap := newtotalheap
- )
-
- caption := ("cumul free sys: " +
- ((newfreesys - startfreesys) as String) +
- " cumul used heap: " +
- (((newtotalheap - newfreeheap) - (starttotalheap - startfreeheap)) as String) +
- " cumul total heap: " +
- ((newtotalheap - starttotalheap) as String))
- print caption
-
- caption := ("adj cumul free sys: " +
- (((newfreesys - startfreesys) + (newtotalheap - starttotalheap)) as String))
- print caption
-
- --memoryusage(20)
- OK
- )
- >>>
-